package com.jf.core;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

import com.jfinal.aop.Interceptor;
import com.jfinal.core.ActionInvocation;

/**
 * 异常处理
 * @author boshouhai
 *
 */
public class ExceptionInterceptor implements Interceptor {

	@Override
	public void intercept(ActionInvocation arg0) {
		try {
			arg0.invoke();
		} catch (Exception e) {
			System.out.println("========"+arg0.getClass());
			System.out.println("========"+arg0.getController().getClass());
//			System.out.println("========"+arg0.getActionKey());
//			System.out.println("-------->Exception1="+e.getMessage());
//			System.out.println("-------->Exception2="+e.toString());
			Logger logger = LogManager.getLogger(arg0.getController().getClass());
			logger.info(" Method="+arg0.getMethodName()+",Url="+arg0.getActionKey()+":"+e.getMessage()+","+e.toString());
			arg0.getController().render("/common/error_404.html");
		}
	}

}
